#ifndef  _SBL_IAP_H
#define  _SBL_IAP_H

extern const unsigned sector_start_map[];
extern const unsigned sector_end_map[];
extern const unsigned crp;

extern unsigned result_table[5];


unsigned write_flash(unsigned * dst, char * src, unsigned no_of_bytes);
void execute_user_code(void);
BOOL user_code_present(void);
BOOL user_code_present(void);
void erase_user_flash(void);
void check_isp_entry_pin(void);
void erase_user_flash(void);

void write_data(unsigned cclk,unsigned flash_address,unsigned * flash_data_buf, unsigned count);
void read_data(unsigned flash_address, unsigned char * flash_data_buf, unsigned count);
void erase_sector(unsigned start_sector,unsigned end_sector,unsigned cclk);
void prepare_sector(unsigned start_sector,unsigned end_sector,unsigned cclk);


typedef enum
{
PREPARE_SECTOR_FOR_WRITE	=50,
COPY_RAM_TO_FLASH			=51,
ERASE_SECTOR				=52,
BLANK_CHECK_SECTOR			=53,
READ_PART_ID				=54,
READ_BOOT_VER				=55,
COMPARE						=56,
REINVOKE_ISP				=57
}IAP_Command_Code;

#define CMD_SUCCESS 0
#define IAP_ADDRESS 0x1FFF1FF1

#endif /* _SBL_IAP_H */
